package tool

import (
	"crypto/md5"
	"encoding/hex"
	"math/rand"
	"strconv"
	"time"
)

func GetMD5String(code string) string {
	h := md5.New()
	h.Write([]byte(code))
	return hex.EncodeToString(h.Sum(nil))
}

func GetSaltMD5String(code string) (int, string) {
	md5String := GetMD5String(code)
	rand.Seed(time.Now().Unix())
	salt := rand.Intn(100)
	return salt, GetMD5String(strconv.Itoa(salt) + md5String)
}
